package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.query.DestinationQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/destination")
public class DestinationController {

   @Reference
   private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo")DestinationQuery qo, Model model){
        PageInfo pageInfo = destinationService.query(qo);
        model.addAttribute("pageInfo",pageInfo);

        //吐司数据共享
        model.addAttribute("toasts",destinationService.getToasts(qo.getParentId()));

        return "destination/list";
    }

    @RequestMapping("/changeHotValue")
    @ResponseBody
    public Object changeHotValue(Boolean hot,Long id){
        destinationService.changeHotValue(hot,id);
        return new AjaxResult();
    }

    @RequestMapping("/setInfo")
    @ResponseBody
    public Object setInfo(String info,Long id){
        destinationService.setInfo(info,id);
        return new AjaxResult();
    }

}
